$('#user_change_password_save_submit').click(function(e) {
    e.preventDefault();
    var btn = $(this);
    var form = $(this).closest('form');

    form.validate({
        rules: {
            original_password: {
                required: true,
                remote: {
                    url: "check.php",
                    type: "post",
                    data: {
                        username: function() {
                            return $( "#username" ).val();
                        }
                    }
                }
            },
            new_password: {
                required: true
            },
            confirm_password: {
                required: true,
                equalTo: "#new_password"
            }
        },
        messages:{
            original_password:{
                required: "必须输入原密码",
                remote: "您输入的原密码不正确"
            },
            new_password:{
                required: "必须输入新密码"
            },
            confirm_password:{
                required: "必须重新输入密码",
                equalTo: "两次输入的密码不同"
            }
        }
    });

    if (!form.valid()) {
        return;
    }

    btn.addClass('m-loader m-loader--right m-loader--light').attr('disabled', true);

    form.ajaxSubmit({
        url: '',
        success: function(response, status, xhr, $form) {
            // similate 2s delay
            setTimeout(function() {
                btn.removeClass('m-loader m-loader--right m-loader--light').attr('disabled', false);
                showErrorMsg(form, 'danger', 'Incorrect username or password. Please try again.');
            }, 2000);
        }
    });
});